namespace OnePiece.Ui.Controls
{
    using System;
    using System.IO;
    using System.Web.Mvc;

    using OnePiece.Core.Extension;
    using OnePiece.Ui.Controls.UI;
    using OnePiece.Ui.Controls.Enumeration;
    using System.Collections.Generic;

    /// <summary>
    /// Displays a grid view in an ASP.NET MVC view.
    /// </summary>
    public class SwappingList : jQueryViewComponentBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SwappingList"/> class.
        /// </summary>
        /// <param name="viewContext">The view context.</param>
        /// <param name="clientSideObjectWriterFactory">The client side object writer factory.</param>
        public SwappingList(ViewContext viewContext, IClientSideObjectWriterFactory clientSideObjectWriterFactory)
            : base(viewContext, clientSideObjectWriterFactory)
        {
            //initialize default value
            LeftListTitle = "Current Items";
            RightListTitle = "Available Items";
            MoveAllToRightButtonText = ">>|";
            MoveAllToLeftButtonText = "|<<";
            MoveToRightButtonText = ">>";
            MoveToLeftButtonText = "<<";
        }


       


        /// <summary>
        /// Defines the title of left list
        /// </summary>
        public string LeftListTitle { get; set; }

        /// <summary>
        /// Defines the title of right list
        /// </summary>
        public string RightListTitle { get; set; }

        /// <summary>
        /// Defines the left List
        /// </summary>
        public Grid LeftList { get; set; }

        /// <summary>
        /// Defines the Right List
        /// </summary>
        public Grid RightList { get; set; }

        /// <summary>
        /// Defines the textname that will be displayed in move all to left button
        /// </summary>
        public string MoveAllToLeftButtonText { get; set; }

        /// <summary>
        /// Defines the textname that will be displayed in move all to right button
        /// </summary>
        public string MoveAllToRightButtonText { get; set; }

        /// <summary>
        /// Defines the textname that will be displayed in move to left button
        /// </summary>
        public string MoveToLeftButtonText { get; set; }

        /// <summary>
        /// Defines the textname that will be displayed in move to right button
        /// </summary>
        public string MoveToRightButtonText { get; set; }

        /// <summary>
        /// Writes the HTML.
        /// </snummary>
        protected override void WriteHtml()
        {
            TextWriter writer = ViewContext.HttpContext.Response.Output;

            if (!string.IsNullOrEmpty(Theme))
            {
                writer.Write("<div class=\"{0}\">".FormatWith(Theme));
            }

            ////main table
            //var tagBuilder = new TagBuilder("table");
            //tagBuilder.MergeAttributes(HtmlAttributes);
            //tagBuilder.GenerateId(Name);
            //writer.Write(tagBuilder.ToString(TagRenderMode.Normal));

            ////pager div
            //tagBuilder = new TagBuilder("div");
            //tagBuilder.MergeAttributes(HtmlAttributes);
            //tagBuilder.GenerateId("{0}_pager".FormatWith(Name));
            //writer.Write(tagBuilder.ToString(TagRenderMode.Normal));


            if (!string.IsNullOrEmpty(Theme))
            {
                writer.Write("</div>");
            }

            base.WriteHtml();
        }

        /// <summary>
        /// Writes the initialization script.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public override void WriteInitializationScript(TextWriter writer)
        {
            //IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "jqSwappingList", writer);

            //objectWriter.Start()
            //    //.Append("mtype", RequestType.ToName().ToUpper())
            //  .Complete();

            //base.WriteInitializationScript(writer);
        }
    }
}